﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using FanaticRock.MediaSource.BilibiliAPI.Enums;

namespace FanaticRock.MediaSource.BilibiliAPI.ResponseDto.Player.Wbi
{
    public class PlayUrlResponseDto : BaseResponseDto
    {
        ///<summary>DurlDto</summary>
        public class DurlDto : BaseDto
        {
            [JsonPropertyName("order")]
            public int order { get; set; }

            [JsonPropertyName("length")]
            public long length { get; set; }

            [JsonPropertyName("size")]
            public long size { get; set; }

            [JsonPropertyName("ahead")]
            public string ahead { get; set; }

            [JsonPropertyName("vhead")]
            public string vhead { get; set; }

            [JsonPropertyName("url")]
            public string url { get; set; }

            [JsonPropertyName("backup_url")]
            public string[] backup_url { get; set; }
        }

        public class MediaDto : BaseDto
        {
            [JsonPropertyName("id")]
            public long Id { get; set; }

            [JsonPropertyName("baseUrl")]
            public string BaseUrl { get; set; }

            [JsonPropertyName("backupUrl")]
            public string[] BackupUrl { get; set; }

        }

        public class DashDto : BaseDto
        {
            [JsonPropertyName("duration")]
            public double Duration { get; set; }

            [JsonPropertyName("minBufferTime")]
            public double MinBufferTime { get; set; }

            [JsonPropertyName("video")]
            public MediaDto[] Video { get; set; }

            [JsonPropertyName("audio")]
            public MediaDto[] Audio { get; set; }

        }

        public class DataDto : BaseDto
        {
            [JsonPropertyName("from")]
            public string From { get; set; }

            [JsonPropertyName("result")]
            public string Result { get; set; }

            [JsonPropertyName("message")]
            public string Message { get; set; }

            [JsonPropertyName("quality")]
            public int Quality { get; set; } // TODO 

            [JsonPropertyName("format")]
            public string Format { get; set; }

            [JsonPropertyName("timelength")]
            public long TimeLength { get; set; } // 单位为毫秒。

            [JsonPropertyName("accept_format")]
            public string AcceptFormat { get; set; }

            [JsonPropertyName("accept_description")]
            public string[] AcceptDescription { get; set; }

            [JsonPropertyName("accept_quality")]
            public QnEnum[] AcceptQuality { get; set; }

            [JsonPropertyName("video_codecid")]
            public long VideoCodeCid { get; set; }

            [JsonPropertyName("seek_param")]
            public string SeekParam { get; set; }

            [JsonPropertyName("seek_type")]
            public string SeekType { get; set; }

            //[JsonPropertyName("durl")]
            //public DurlDto[] Durl { get; set; }

            [JsonPropertyName("dash")]
            public DashDto Dash { get; set; }

            [JsonPropertyName("support_formats")]
            public FormatDto[] SupportFormats { get; set; }

            [JsonPropertyName("high_format")]
            public string HighFormat { get; set; }

            [JsonPropertyName("last_play_time")]
            public long LastPlayTime { get; set; }

            [JsonPropertyName("last_play_cid")]
            public long LastPlayCid { get; set; }


        }

        [JsonPropertyName("data")]
        public DataDto Data { get; set; }
    }
}
